using System;
using System.Text;
using System.Data;
using System.Data.Sql;
using System.Collections.Generic;
using System.Reflection;

namespace Xdt.Fnb.Data
{
  /// <summary>
  /// PrintQueue Data Object Class
  /// </summary>
  public partial class DOPrintQueue
  {
    #region Class Constant declarations
    		/// <summary>
		/// The Table Column for the PrintQueue Id
		/// </summary>
		public const string RowId = "PrintQueue_ID";

		/// <summary>
		/// The Table Column for the PrintQueue FileName
		/// </summary>
		public const string RowFileName = "FileName";

		/// <summary>
		/// The Table Column for the PrintQueue FilePath
		/// </summary>
		public const string RowFilePath = "FilePath";

		/// <summary>
		/// The Table Column for the PrintQueue UserName
		/// </summary>
		public const string RowUserName = "UserName";

		/// <summary>
		/// The Table Column for the PrintQueue PrinterName
		/// </summary>
		public const string RowPrinterName = "PrinterName";

		/// <summary>
		/// The Table Column for the PrintQueue PrinterFileName
		/// </summary>
		public const string RowPrinterFileName = "PrinterFileName";

		/// <summary>
		/// The Table Column for the PrintQueue PrintCopies
		/// </summary>
		public const string RowPrintCopies = "PrintCopies";

		/// <summary>
		/// The Table Column for the PrintQueue Date
		/// </summary>
		public const string RowDate = "Date";

		/// <summary>
		/// The Table Column for the PrintQueue Printed
		/// </summary>
		public const string RowPrinted = "Printed";

		/// <summary>
		/// The Table Column for the PrintQueue PrintedDate
		/// </summary>
		public const string RowPrintedDate = "PrintedDate";


#region Stored Procedures
private const string m_StoredProcedureConstCreate = "spPrintQueue_Create";
private const string m_StoredProcedureConstDelete = "spPrintQueue_Delete";
private const string m_StoredProcedureConstRetrieve = "spPrintQueue_Retrieve";
private const string m_StoredProcedureConstRetrieveall = "spPrintQueue_Retrieveall";
private const string m_StoredProcedureConstUpdate = "spPrintQueue_Update";
#endregion
    
    
    #endregion

    #region Class Variable declarations
    	#region DO Variables
		private int m_Id;
		private string m_FileName;
		private string m_FilePath;
		private string m_UserName;
		private string m_PrinterName;
		private string m_PrinterFileName;
		private int m_PrintCopies;
		private DateTime m_Date;
		private bool m_Printed;
		private DateTime m_PrintedDate;
	#endregion
    
	#region Default Variables
	private SQLDataObject sqlData;
	private List<DOPrintQueue> m_PrintQueues = new List<DOPrintQueue>();
	#endregion
	
    #endregion

    #region Class Constructors & Destructors
    /// <summary>
    /// Class Constructor
    /// </summary>
    public DOPrintQueue() { }
    #endregion

    #region Class Properties
    #region DO Properties
		/// <summary>
		/// Id
		/// </summary>
		/// <remarks>
		/// This property contains the PrintQueue Id
		/// </remarks>
		public int Id
		{
			get { return (this.m_Id); }
			set { this.m_Id = value; }
		}

		/// <summary>
		/// FileName
		/// </summary>
		/// <remarks>
		/// This property contains the PrintQueue FileName
		/// </remarks>
		public string FileName
		{
			get { return (this.m_FileName); }
			set { this.m_FileName = value; }
		}

		/// <summary>
		/// FilePath
		/// </summary>
		/// <remarks>
		/// This property contains the PrintQueue FilePath
		/// </remarks>
		public string FilePath
		{
			get { return (this.m_FilePath); }
			set { this.m_FilePath = value; }
		}

		/// <summary>
		/// UserName
		/// </summary>
		/// <remarks>
		/// This property contains the PrintQueue UserName
		/// </remarks>
		public string UserName
		{
			get { return (this.m_UserName); }
			set { this.m_UserName = value; }
		}

		/// <summary>
		/// PrinterName
		/// </summary>
		/// <remarks>
		/// This property contains the PrintQueue PrinterName
		/// </remarks>
		public string PrinterName
		{
			get { return (this.m_PrinterName); }
			set { this.m_PrinterName = value; }
		}

		/// <summary>
		/// PrinterFileName
		/// </summary>
		/// <remarks>
		/// This property contains the PrintQueue PrinterFileName
		/// </remarks>
		public string PrinterFileName
		{
			get { return (this.m_PrinterFileName); }
			set { this.m_PrinterFileName = value; }
		}

		/// <summary>
		/// PrintCopies
		/// </summary>
		/// <remarks>
		/// This property contains the PrintQueue PrintCopies
		/// </remarks>
		public int PrintCopies
		{
			get { return (this.m_PrintCopies); }
			set { this.m_PrintCopies = value; }
		}

		/// <summary>
		/// Date
		/// </summary>
		/// <remarks>
		/// This property contains the PrintQueue Date
		/// </remarks>
		public DateTime Date
		{
			get { return (this.m_Date); }
			set { this.m_Date = value; }
		}

		/// <summary>
		/// Printed
		/// </summary>
		/// <remarks>
		/// This property contains the PrintQueue Printed
		/// </remarks>
		public bool Printed
		{
			get { return (this.m_Printed); }
			set { this.m_Printed = value; }
		}

		/// <summary>
		/// PrintedDate
		/// </summary>
		/// <remarks>
		/// This property contains the PrintQueue PrintedDate
		/// </remarks>
		public DateTime PrintedDate
		{
			get { return (this.m_PrintedDate); }
			set { this.m_PrintedDate = value; }
		}
		#endregion
    
	#region Default Properties
	public List<DOPrintQueue> PrintQueues
	{
	  get { return m_PrintQueues; }
	  set { m_PrintQueues = value; }
	}    
	#endregion
	
    #endregion

    #region Class Methods
    public bool Retrieve()
    {
      sqlData = new SQLDataObject();
      DataSet resultDS = sqlData.ExecuteDataSetSQL(m_StoredProcedureConstRetrieve + " @" + RowPrintQueue_ID + "=" + this.PrintQueue_ID);
      return SetClassPropertiesFromDataSet(resultDS);
    }

    public bool RetrieveAll()
    {
      sqlData = new SQLDataObject();
      string sVariables = sqlData.GetVariables(this);

      DataSet resultDS = sqlData.ExecuteDataSetSQL(m_StoredProcedureConstRetrieveall + " " + sVariables.Substring(0, sVariables.Length - 2));
      return SetClassPropertiesListFromDataSet(resultDS);
    }

    public bool Create()
    {
      bool success = false;
      sqlData = new SQLDataObject();
      string sVariables = sqlData.GetVariables(this);

      success = sqlData.ExecuteNonQuerySQL(m_StoredProcedureConstCreate + " " + sVariables.Substring(0, sVariables.Length - 2));

      return success;
    }

    public bool Update()
    {
      bool success = false;
      sqlData = new SQLDataObject();

      string sVariables = sqlData.GetVariables(this);

      success = sqlData.ExecuteNonQuerySQL(m_StoredProcedureConstUpdate + " " + sVariables.Substring(0, sVariables.Length - 2));

      return success;
    }

    private bool SetClassPropertiesFromDataSet(DataSet resultDS)
    {
      bool success = false;
      if (resultDS.Tables[0] != null)
      {
        if (resultDS.Tables[0].Rows.Count > 0)
        {
          foreach (DataRow dr in resultDS.Tables[0].Rows)
          {
					if (dr[RowId].ToString() != "")
			this.Id = int.Parse(dr[RowId].ToString());

		if (dr[RowFileName].ToString() != "")
			this.FileName = dr[RowFileName].ToString();

		if (dr[RowFilePath].ToString() != "")
			this.FilePath = dr[RowFilePath].ToString();

		if (dr[RowUserName].ToString() != "")
			this.UserName = dr[RowUserName].ToString();

		if (dr[RowPrinterName].ToString() != "")
			this.PrinterName = dr[RowPrinterName].ToString();

		if (dr[RowPrinterFileName].ToString() != "")
			this.PrinterFileName = dr[RowPrinterFileName].ToString();

		if (dr[RowPrintCopies].ToString() != "")
			this.PrintCopies = int.Parse(dr[RowPrintCopies].ToString());

		if (dr[RowDate].ToString() != "")
			this.Date = DateTime.Parse(dr[RowDate].ToString());

		if (dr[RowPrinted].ToString() != "")
			this.Printed = bool.Parse(dr[RowPrinted].ToString());

		if (dr[RowPrintedDate].ToString() != "")
			this.PrintedDate = DateTime.Parse(dr[RowPrintedDate].ToString());
          }
          success = true;
        }
      }
      return success;
    }

    private bool SetClassPropertiesListFromDataSet(DataSet resultDS)
    {
      bool success = false;
      if (resultDS.Tables[0] != null)
      {
        if (resultDS.Tables[0].Rows.Count > 0)
        {
          foreach (DataRow dr in resultDS.Tables[0].Rows)
          {
            DOPrintQueue PrintQueue = new DOPrintQueue();
			
					if (dr[RowId].ToString() != "")
			PrintQueue.Id = int.Parse(dr[RowId].ToString());

		if (dr[RowFileName].ToString() != "")
			PrintQueue.FileName = dr[RowFileName].ToString();

		if (dr[RowFilePath].ToString() != "")
			PrintQueue.FilePath = dr[RowFilePath].ToString();

		if (dr[RowUserName].ToString() != "")
			PrintQueue.UserName = dr[RowUserName].ToString();

		if (dr[RowPrinterName].ToString() != "")
			PrintQueue.PrinterName = dr[RowPrinterName].ToString();

		if (dr[RowPrinterFileName].ToString() != "")
			PrintQueue.PrinterFileName = dr[RowPrinterFileName].ToString();

		if (dr[RowPrintCopies].ToString() != "")
			PrintQueue.PrintCopies = int.Parse(dr[RowPrintCopies].ToString());

		if (dr[RowDate].ToString() != "")
			PrintQueue.Date = DateTime.Parse(dr[RowDate].ToString());

		if (dr[RowPrinted].ToString() != "")
			PrintQueue.Printed = bool.Parse(dr[RowPrinted].ToString());

		if (dr[RowPrintedDate].ToString() != "")
			PrintQueue.PrintedDate = DateTime.Parse(dr[RowPrintedDate].ToString());

            this.PrintQueues.Add(PrintQueue);
          }
          success = true;
        }
      }
      return success;
    }
    #endregion

    #region Class Support Methods
    #endregion
  }
}
